<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>全局变量</title>
		<script type="text/javascript">
			window.onload=function(){
				var mybtn1=document.getElementById("btn1");
				var mybtn2=document.getElementById("btn2");
				
				//声明一个全局变量 ,初始值为100;
				var a=100;
				
				mybtn1.onclick=function(){
					a++;//自加1
					console.log(a);
				}
				mybtn2.onclick=function(){
					a--;//自减1
					console.log(a);
				}
			}
		</script>
	</head>
	<body>
		<input type="button" id="btn1" value="按钮1" />
		<input type="button" id="btn2" value="按钮2" />
	</body>
</html>
